< previous page page_121 next page >

Page 121
Notice that when you first start the form, the combo box shows an empty value. This indicates no selection has been made. You can add some code to your form that selects a default item from the list, too. Add the following line of code to the Form_Load event:
cboCustType.ListIndex = 0 ' set default value
Now when the form starts, you see the first value in the list has already been selected.
Up to this point, you have been developing methods for handling field-level validation. The next step is to add validation routines at the form level.
Form-Level Validation
Form-level validation is an essential part of designing a good validation scheme for your form. Although many input errors can be caught and corrected at the field level, there are several validation steps that can only be performed well at the form level.
Although field-level validation is performed at the time a key is pressed or at the time a field loses focus, form-level validation is performed at the time the user presses Enter, or clicks the OK or Save button. These are validations that are done after the user has entered all fields, but before any attempt is made to store the values to a data table.
Form-level validation can be divided into three groups:
· Independent content validation
· Required field validation
· Dependent field validation
Let's look at each type of form-level validation.
Independent Content ValidationHigh/Low Ranges
A common form-level validation routine is one that checks the upper and lower values of a numeric entry and makes sure the value is within the high/low range. This is very useful on all types of forms that have dollar amounts or unit count minimum and maximum values.
Note.gif
Although it might seem that this kind of validation should be done at the field level, it is better to perform it at the form level. If a user enters a value that is not within the acceptable range, the field that contains the invalid data must be given focus so that the user can correct the

 
< previous page page_121 next page >

If you like this book, buy it!